export default {
	namespaced: true,
	state() {
		return {
			weather: JSON.parse(uni.getStorageSync('weather') || '{}'),
			location: JSON.parse(uni.getStorageSync('location') || '{}'),
		}
	},
	mutations: {
		updateWeather(state, payload) {
			state.weather = payload
			this.commit('weather/saveWeatherToStorage')
		},
		saveWeatherToStorage(state) {
			uni.setStorageSync('weather', JSON.stringify(state.weather))
		},
		updateLocation(state, payload) {
			state.location = payload
			this.commit('weather/saveLocationToStorage')
			console.log('更新经纬度信息成功', state.location);
		},
		saveLocationToStorage(state) {
			uni.setStorageSync('location', JSON.stringify(state.location))
		}
	}
}